A number of changes to get save-restore working again:
authoremellor@ewan <emellor@ewan>
Thu, 22 Sep 2005 15:05:44 +0000 (16:05 +0100)
committeremellor@ewan <emellor@ewan>
Thu, 22 Sep 2005 15:05:44 +0000 (16:05 +0100)
Fix the use of configuration inside domain_configure.  The config written by
XendDomainInfo.sxpr has moved, and this function needs to change to match.

Re-add a call to _add_domain inside domain_restore.

Inside XendDomainInfo.restore, perform the appropriate configuration to restore
the domain.

Validate maxmem_KiB, and cap it at memory_KiB if over that value.  Save
requires that value to be correct, as the logic for saving only the pages
in use is not in place inside Xen.

Output the device configuration in sxpr(), as required for save-restore.

Check for image being null when trying to call createDeviceModel -- configure
is called on restore as well as create, and the ImageHandler instance is not
present in the former.

Remove dead code create_blkif.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/XendDomain.py
tools/python/xen/xend/XendDomainInfo.py

index 76d4fce4a9e4f9111db07d2a692288854e31e6e6..b790f3172643a2c2d36337f35ed21474488256f8 100644 (file)
@@ -299,13 +299,12 @@ class XendDomain:
                            [dominfo.getName(), dominfo.getDomain(), "fail"])
         return dominfo
 
-    def domain_configure(self, vmconfig):
+    def domain_configure(self, config):
         """Configure an existing domain. This is intended for internal
         use by domain restore and migrate.
 
         @param vmconfig: vm configuration
         """
-        config = sxp.child_value(vmconfig, 'config')
         return XendDomainInfo.restore(self.dbmap.getPath(), config)
 
     def domain_restore(self, src, progress=False):
@@ -317,7 +316,9 @@ class XendDomain:
 
         try:
             fd = os.open(src, os.O_RDONLY)
-            return XendCheckpoint.restore(self, fd)
+            dominfo = XendCheckpoint.restore(self, fd)
+            self._add_domain(dominfo)
+            return dominfo
         except OSError, ex:
             raise XendError("can't read guest state file %s: %s" %
                             (src, ex[1]))
@@ -502,7 +503,7 @@ class XendDomain:
         """
 
         if domid == PRIV_DOMAIN:
-            raise XendError("Cannot destroy priviliged domain %i" % domid)
+            raise XendError("Cannot destroy privileged domain %i" % domid)
         
         self.domain_restart_schedule(domid, reason, force=True)
         dominfo = self.domain_lookup(domid)
index b59adbdf350cd2d40c2e16a48e203108ee874015..5dab516d8082c456e778754dd53fbc8eb0fdd06c 100644 (file)
@@ -172,7 +172,7 @@ class XendDomainInfo:
         @param uuid:      uuid to use
         """
         
-        log.debug("XendDomainInfo.restore(%s, ..., %s)", dompath, uuid)
+        log.debug("XendDomainInfo.restore(%s, %s, %s)", dompath, config, uuid)
 
         if not uuid:
             uuid = getUuid()
@@ -187,6 +187,9 @@ class XendDomainInfo:
         vm = cls(uuid, dompath, cls.parseConfig(config),
                  xc.domain_create(ssidref = ssidref))
         vm.clear_shutdown()
+        vm.create_channel()
+        vm.configure()
+        vm.exportToDB()
         return vm
 
     restore = classmethod(restore)
@@ -382,6 +385,9 @@ class XendDomainInfo:
             if not self.info['maxmem_KiB']:
                 self.info['maxmem_KiB'] = 1 << 30
 
+            if self.info['maxmem_KiB'] > self.info['memory_KiB']:
+                self.info['maxmem_KiB'] = self.info['memory_KiB']
+
             # Validate the given backend names.
             for s in self.info['backend']:
                 if s not in backendFlags:
@@ -607,6 +613,10 @@ class XendDomainInfo:
         if self.info:
             sxpr.append(['maxmem', self.info['maxmem_KiB'] / 1024])
 
+            if self.infoIsSet('device'):
+                for (n, c) in self.info['device']:
+                    sxpr.append(['device', c])
+
             def stateChar(name):
                 if name in self.info:
                     if self.info[name]:
@@ -864,7 +874,8 @@ class XendDomainInfo:
         """
         if not self.rebooting():
             self.create_configured_devices()
-        self.image.createDeviceModel()
+        if self.image:
+            self.image.createDeviceModel()
 
     def device_create(self, dev_config):
         """Create a new device.
@@ -979,15 +990,6 @@ class XendDomainInfo:
         """
         self.configure_maxmem()
         self.create_devices()
-        self.create_blkif()
-
-    def create_blkif(self):
-        """Create the block device interface (blkif) for the vm.
-        The vm needs a blkif even if it doesn't have any disks
-        at creation time, for example when it uses NFS root.
-
-        """
-        return
 
 
     def configure_maxmem(self):